/*$(function(){
	
//	主模块
	var vm = new Vue({
		el:'#Main',
		data:{
			caseData:data.case,
		},
		methods:{
			//取消关注
			cancelFollow:function(id){
				dmAlert('确定要取消关联？',{
					success:function(){
						tip('取消成功');
					},
				});
			},
		},
		created:function(){
			imgRate();
		},
		mounted:function(){
			pullSwiper("#Main",{
				up:true,//启动下拉刷新,也可自定义函数，默认禁用
				down:true,//启用上拉加载,也可自定义函数，默认禁用
			});
		},
	});
	
//	顶部案例筛选模块
	var screen = new Vue({
		el:'#screenMod',
		data:{
			style:null,
			area:null,
			home:null
		},
		methods:{
			//案例-单项筛选
			screen:function(e,type){
				var team = $("#screenMod dl");
				for(i in team){
					if(i != type){
						team.eq(i).removeClass('active');
					};
				};
				
				var that = this;
				var target = e.currentTarget;
				var checkIndex = target.getAttribute('data-check');
				var arr = data.caseScreen[type].list;
				
				if(target.className.indexOf('active') < 0 ){
					//展开
					target.className = 'flex-full flex-row active';
					caseRadio(arr,checkIndex,function(index){
						if(type==0){
							if(index==0){
								that.style = null;
							}else{
								that.style = arr[index];
							};
						}else if(type==1){
							if(index==0){
								that.area = null;
							}else{
								that.area = arr[index];
							};
						}else{
							if(index==0){
								that.home = null;
							}else{
								that.home = arr[index];
							};
						};
						target.setAttribute('data-check',index);
						target.className = 'flex-full flex-row';
					});
				}else{
					//收起
					target.className = 'flex-full flex-row';
					$("#screenMask").hide(function(){
						$("#screenMask").remove();
					});
				};
				
			},
			
			//案例-多项筛选
			check:function(){
				
				$("#screenMod dl").removeClass('active');
				$("#screenMask").remove();
				
				var that = this;
				var checkArr = [];
				
				for(var i=0;i<3;i++){
					var check = $("#screenMod dl").eq(i).attr('data-check');
					checkArr.push(check);
				};
				var listData = [
				
					{arr:data.caseScreen[0].list,check:checkArr[0]},
					{arr:data.caseScreen[1].list,check:checkArr[1]},
					{arr:data.caseScreen[2].list,check:checkArr[2]}
				];
				
				caseCheckAll(listData,function(arr){
					for(i in arr){
						$("#screenMod dl").eq(i).attr('data-check',arr[i]);
					};
					
					if(arr[0]==0){
						that.style = null;
					}else{
						that.style = data.caseScreen[0].list[arr[0]];
					};
					
					if(arr[1]==0){
						that.area = null;
					}else{
						that.area = data.caseScreen[1].list[arr[1]];
					};
					
					if(arr[2]==0){
						that.home = null;
					}else{
						that.home = data.caseScreen[2].list[arr[2]];
					};
				});
				
			},
			
		},
	});
	
});


//案例多项筛选
function caseCheckAll(data,callback){
	
	var styleHtml = '';
	var areaHtml = '';
	var homeHtml = '';
	
	var arr = [];
	
	for(i in data){
		if(i==0){
			//风格
			for(j in data[i].arr){
				if(j == data[i].check){
					styleHtml += `<span class="on bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				}else{
					styleHtml += `<span class="bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				};
			};
		}else if(i==1){
			//面积
			for(j in data[i].arr){
				if(j == data[i].check){
					areaHtml += `<span class="on bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				}else{
					areaHtml += `<span class="bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				};
			};
		}else{
			//户型
			for(j in data[i].arr){
				if(j == data[i].check){
					homeHtml += `<span class="on bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				}else{
					homeHtml += `<span class="bottom-line" data-check="${j}">${data[i].arr[j]}</span>`;
				};
			};
		};
	};
	
	$('body').append(`
		<div id="screenMask">
			<div class="subMain animate">
				<footer class="footer top-line tc h4 main-line flex-row" id="allCaseBtn">
					<a class="reset flex-full">重置</a>
					<a class="enter flex-full">确定</a>
				</footer>
				<div class="swiper-container Main" id="caseAllSel" style="top:0;">
					<div class="swiper-wrapper">
						<div class="swiper-slide content">
							
							<div class="children">
								<h5 class="dm-title bottom-line">风格</h5>
								<div class="list h5">
									${styleHtml}	
								</div>
								<h5 class="dm-title bottom-line">面积</h5>
								<div class="list h5">
									${areaHtml}	
								</div>
								<h5 class="dm-title bottom-line">户型</h5>
								<div class="list h5">
									${homeHtml}	
								</div>
							</div>
							
						</div>
					</div>
				</div>
				
			</div>
			
		</div>	
	`);
	
	pullSwiper("#caseAllSel");
	
	$("#screenMask .subMain").css('transform','translate3d(0,0,0)');
	
	//单项选择
	$("#caseAllSel .list").each(function(){
		$(this).children().click(function(){
			var target = $(this);
			target.addClass('on').siblings().removeClass('on');
		});
	});
	
	//重置
	$("#allCaseBtn .reset").click(function(){
		$("#caseAllSel").find('.list').each(function(i){
			var nodes = $(this).children();
			for(i in nodes){
				var check = nodes.eq(i).attr('data-check');
				if(check == 0){
					nodes.eq(i).addClass('on');
				}else{
					nodes.eq(i).removeClass('on');
				};
			};
		});
		if(typeof callback == 'function'){
			arr = [0,0,0];
			callback(arr);
		};
		$("#screenMask .subMain").remove();
		
	});
	
	//确定
	$("#allCaseBtn .enter").click(function(){
		$("#caseAllSel").find('.list').each(function(i){
			var check = $(this).children('.on').attr('data-check');
			arr.push(check);
		});
		if(typeof callback == 'function'){
			callback(arr);
		};
		$("#screenMask .subMain").remove();
	});
};*/


$(function(){
	
	var vm = new Vue({
		el:'#doumee',
		data:{
			caseData:data.case,
			kitchenArr:data.kitchenScreen,
			homeArr:data.caseScreen,
			arr:[],
			sel:[0,0,0],
			type:0,
		},
		methods:{
			//案例切换
			caseTab:function(type){
				this.type = type;
				this.sel = [0,0,0];
				this.getType();
			},
			//判断type类型
			getType:function(){
				if(this.type==0){
					//厨柜
					this.arr = this.kitchenArr;
				}else{
					//全屋
					this.arr = this.homeArr;
				};
			},
			//多选
			check:function(){
				//打开多选项
				openSubMain('#screenMask');
			},
			//选项切换
			checkOpt:function(index,value){
				this.sel.splice(index,1,value);
			},
			//重置
			resetOpt:function(){
				this.sel = [0,0,0];
				closeSubMain($("#screenMask"));
			},
			//确认筛选
			enterOpt:function(){
				console.log(this.sel);
				closeSubMain($("#screenMask"));
			},
			//跳转详情
			skipDtl:function(id){
				if(this.type == 0){
					//厨柜详情
					location.href='kitchenDetail.html?caseId='+id;
				}else{
					//全屋详情
					location.href='caseDetail.html?caseId='+id;
				};
			},
			//取消关注
			cancelFollow:function(id){
				dmAlert('确定要取消关联？',{
					success:function(){
						tip('取消成功');
					},
				});
			},
		},
		created:function(){
			imgRate();
		},
		mounted:function(){
			this.getType();
			pullSwiper('#Main',{
				up:true,
				down:true,
			});
			pullSwiper('#caseAllSel');
		},
	})
	
});





//下拉刷新
function refresh(pull){
	pull.innerHTML='刷新完成';
};

//上拉加载
function reload(pull){
	pull.innerHTML='已加载全部数据';
};

